package com.tepth.maintenancesystem.bean;

import android.os.Parcel;
import android.os.Parcelable;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by LHQ on 2016/12/19.
 */

public class MaintainListWork implements Parcelable {
    private String contentTypeCode;
    private String contentTypeName;
    private String confirmPersonCode;
    private String confirmPersonName;
    private String confirmTime;
    private String confirmMonitorCode;
    private String confirmMonitorName;
    private String confirmMonitorTime;
    private String completedRemark;
    private int temp_select_number;//操作了Contents集合的数量
    private List<Contents> listContents;
    private boolean isGuojian;

    public MaintainListWork(){

    }

    public MaintainListWork(JSONObject object)throws Exception{
        this.contentTypeCode=object.getString("ContentTypeCode");
        this.contentTypeName=object.getString("ContentTypeName");
        this.confirmPersonCode=object.getString("ConfirmPersonCode");
        this.confirmPersonName=object.getString("ConfirmPersonName");
        this.confirmTime=object.getString("ConfirmTime");
        this.confirmMonitorCode=object.getString("ConfirmMonitorCode");
        this.confirmMonitorName=object.getString("ConfirmMonitorName");
        this.confirmMonitorTime=object.getString("ConfirmMonitorTime");
        this.completedRemark=object.getString("CompletedRemark");
        listContents=new ArrayList<>();
        JSONArray array=object.getJSONArray("ListContents");
        for (int i=0;i<array.length();i++){
            listContents.add(new Contents(array.getJSONObject(i)));
        }
        this.temp_select_number=0;
        this.isGuojian=false;
    }

    protected MaintainListWork(Parcel in) {
        contentTypeCode = in.readString();
        contentTypeName = in.readString();
        confirmPersonCode = in.readString();
        confirmPersonName = in.readString();
        confirmTime = in.readString();
        confirmMonitorCode = in.readString();
        confirmMonitorName = in.readString();
        confirmMonitorTime = in.readString();
        completedRemark = in.readString();
        temp_select_number = in.readInt();
        isGuojian = in.readByte() != 0;
    }

    public static final Creator<MaintainListWork> CREATOR = new Creator<MaintainListWork>() {
        @Override
        public MaintainListWork createFromParcel(Parcel in) {
            return new MaintainListWork(in);
        }

        @Override
        public MaintainListWork[] newArray(int size) {
            return new MaintainListWork[size];
        }
    };

    public String getContentTypeCode() {
        return contentTypeCode;
    }

    public void setContentTypeCode(String contentTypeCode) {
        this.contentTypeCode = contentTypeCode;
    }

    public String getContentTypeName() {
        return contentTypeName;
    }

    public void setContentTypeName(String contentTypeName) {
        this.contentTypeName = contentTypeName;
    }

    public String getConfirmPersonCode() {
        return confirmPersonCode;
    }

    public void setConfirmPersonCode(String confirmPersonCode) {
        this.confirmPersonCode = confirmPersonCode;
    }

    public String getConfirmPersonName() {
        return confirmPersonName;
    }

    public void setConfirmPersonName(String confirmPersonName) {
        this.confirmPersonName = confirmPersonName;
    }

    public String getConfirmTime() {
        return confirmTime;
    }

    public void setConfirmTime(String confirmTime) {
        this.confirmTime = confirmTime;
    }

    public String getConfirmMonitorCode() {
        return confirmMonitorCode;
    }

    public void setConfirmMonitorCode(String confirmMonitorCode) {
        this.confirmMonitorCode = confirmMonitorCode;
    }

    public String getConfirmMonitorName() {
        return confirmMonitorName;
    }

    public void setConfirmMonitorName(String confirmMonitorName) {
        this.confirmMonitorName = confirmMonitorName;
    }

    public String getConfirmMonitorTime() {
        return confirmMonitorTime;
    }

    public void setConfirmMonitorTime(String confirmMonitorTime) {
        this.confirmMonitorTime = confirmMonitorTime;
    }

    public String getCompletedRemark() {
        return completedRemark;
    }

    public void setCompletedRemark(String completedRemark) {
        this.completedRemark = completedRemark;
    }

    public int getTemp_select_number() {
        return temp_select_number;
    }

    public void setTemp_select_number(int temp_select_number) {
        this.temp_select_number = temp_select_number;
    }

    public boolean isGuojian() {
        return isGuojian;
    }

    public void setGuojian(boolean guojian) {
        isGuojian = guojian;
    }

    public List<Contents> getListContents() {
        return listContents;
    }

    public void setListContents(List<Contents> listContents) {
        this.listContents = listContents;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(contentTypeCode);
        parcel.writeString(contentTypeName);
        parcel.writeString(confirmPersonCode);
        parcel.writeString(confirmPersonName);
        parcel.writeString(confirmTime);
        parcel.writeString(confirmMonitorCode);
        parcel.writeString(confirmMonitorName);
        parcel.writeString(confirmMonitorTime);
        parcel.writeString(completedRemark);
        parcel.writeInt(temp_select_number);
        parcel.writeByte((byte) (isGuojian ? 1 : 0));
    }
}
